//使用接口的方式实现多态
interface Animalface {
    public abstract void eat();
    public abstract void sleep();
}
class Cat2 implements Animalface{
    @Override
    public void eat(){
        System.out.println("cat is eating fish");
    }
    @Override
    public void sleep(){
        System.out.println("cat is sleeping on the bed");
    }
}
class Dog2 implements Animalface{
    @Override
    public void eat(){
        System.out.println("Dog is gnawing bone");
    }
    @Override
    public void sleep(){
        System.out.println("Dog is sleeping on the floor");
    }
}
class Raiser2{
    public void feed(Animalface animalface){
        animalface.eat();
        animalface.sleep();
    }
}
public class Example5_6_2{
    public static void main(String[] args){
        Cat2 cat=new Cat2();
        Dog2 dog=new Dog2();
        Raiser2 mike=new Raiser2();
        mike.feed(cat);//animal=cat cat上转型为animal    A a=new B();
        mike.feed(dog);//animal=dog dog上转型为animal
    }
}